using System;
using System.Collections.Generic;

namespace F1RacingGame
{
    public class GameManager
    {
        private static GameManager instance;
        private GameEngine gameEngine;
        
        // 游戏数据
        public int PlayerScore { get; set; } = 0;
        public int PlayerLevel { get; set; } = 1;
        public string SelectedCar { get; set; } = "Ferrari";
        public string SelectedTrack { get; set; } = "Monza";
        public GameDifficulty Difficulty { get; set; } = GameDifficulty.Normal;
        
        // 游戏设置
        public bool SoundEnabled { get; set; } = true;
        public bool MusicEnabled { get; set; } = true;
        public bool DemoEnabled { get; set; } = true;
        public int DemoDuration { get; set; } = 10; // 秒
        
        private GameManager() { }
        
        public static GameManager Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new GameManager();
                }
                return instance;
            }
        }
        
        public void Initialize(GameEngine engine)
        {
            gameEngine = engine;
            LoadGameSettings();
        }
        
        public void ChangeState(GameState newState)
        {
            if (gameEngine != null)
            {
                gameEngine.ChangeState(newState);
            }
        }
        
        public void AddScore(int points)
        {
            PlayerScore += points;
            // 检查是否升级
            if (PlayerScore >= PlayerLevel * 1000)
            {
                PlayerLevel++;
            }
        }
        
        public void SaveGameSettings()
        {
            // TODO: 实现设置保存到文件
        }
        
        public void LoadGameSettings()
        {
            // TODO: 实现从文件加载设置
        }
        
        public void ResetGame()
        {
            PlayerScore = 0;
            PlayerLevel = 1;
        }
    }
    
    public enum GameDifficulty
    {
        Easy,
        Normal,
        Hard
    }
} 